import {Button} from "antd";
import React from "react";



export function setActionHandlersForModal(modalProperties, hideModalHandler){
  modalProperties['onOk'] = hideModalHandler
  modalProperties['onCancel'] = hideModalHandler
}

export function setContextForAGGrid(gridOptions, menuClickHandler){
  if(gridOptions){
    gridOptions.context = {menuClickHandler : menuClickHandler}
  }
}

export function getGridPanelOptions(panelConfiguration){
  let panelOptions = {}

  if(!panelConfiguration){
    return panelOptions
  }

  panelOptions.buttons = getGridHeaderButtons(panelConfiguration.buttonConfigs)


  return panelOptions
}

export function getGridHeaderButtons(buttonConfigs){
  let buttons = []
  forEach(buttonConfigs, (buttonConfig)=>{
    buttons.push(<Button type={buttonConfig.type}  onClick={buttonConfig.clickHandler}>{buttonConfig.name}</Button>)
  })

  return buttons
}
